home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libray / libcommon / common.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  2.5 KB  |  125 lines

  1. /*
  2.  * common.h
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * common.h,v 4.1 1994/08/09 07:54:42 explorer Exp
  17.  *
  18.  * common.h,v
  19.  * Revision 4.1  1994/08/09  07:54:42  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:01  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0.1.1  91/11/26  21:34:27  cek
  26.  * patch3: Added EPSILON definition, redefine equal() macro.
  27.  * 
  28.  * Revision 4.0  91/07/17  14:30:18  kolb
  29.  * Initial version.
  30.  * 
  31.  */
  32. #ifndef COMMON_H 
  33. #define COMMON_H
  34.  
  35. #include <stdio.h>
  36. #include <math.h>
  37. #ifdef I_STDLIB
  38. #include <stdlib.h>
  39. #endif
  40. #include "config.h"
  41.  
  42. typedef double Float;
  43.  
  44. #if (VOIDFLAGS & 8) == 8
  45. typedef void * voidstar;
  46. #else
  47. typedef char * voidstar;
  48. #endif
  49.  
  50. #include "expr.h"
  51. #include "vector.h"
  52. #include "ray.h"
  53. #include "color.h"
  54. #include "transform.h"
  55. #include "error.h"
  56.  
  57. #ifndef TRUE
  58. #define TRUE        1
  59. #endif
  60.  
  61. #ifndef FALSE
  62. #define FALSE        0
  63. #endif
  64.  
  65. /*
  66.  * Various useful constants and macros.
  67.  */
  68.  
  69. /*
  70.  * Minimum vector length & fp value.
  71.  * Modify depending upon Float typedef.
  72.  */
  73. #define EPSILON        (Float)0.00001
  74.  
  75. #ifndef PI
  76. #define    PI        3.14159265358979323846
  77. #endif
  78. #define TWOPI        (2. * PI)
  79. #define INV_TWOPI    (1. / TWOPI)
  80. #define deg2rad(x)    (Float)(x * PI/180.)
  81. #define LNHALF        (-.69314718)
  82.  
  83. #ifndef NULL
  84. #    define NULL 0
  85. #endif
  86.  
  87. #define UNSET        -1
  88.  
  89. /*
  90.  * Some systems, such as the RS6000, have fast fabs already defined.
  91.  */
  92. #ifndef fabs
  93. extern Float RSabstmp;
  94. #define fabs(x)         ((RSabstmp=x) < 0 ? -RSabstmp : RSabstmp)
  95. #endif
  96.  
  97. #ifdef MULTIMAX
  98. /*
  99.  * On the multimax, allocate large pieces of memory as shared memory.
  100.  */
  101. extern char *share_malloc(), *share_calloc();
  102. #else
  103. /*
  104.  * Otherwise, malloc is malloc, etc.
  105.  */
  106. #define share_malloc(x)        Malloc(x)
  107. #define share_calloc(x,y)    Calloc(x,y)
  108. #endif
  109.  
  110. /*
  111.  * Close enough for us.
  112.  */
  113. #define equal(a, b)        (fabs((a) - (b)) < EPSILON)
  114. /*
  115.  * Maximum/Minimum functions
  116.  */
  117. #define max(a, b)        ((a) > (b) ? (a) : (b))
  118. #define min(a, b)        ((a) < (b) ? (a) : (b))
  119.  
  120. extern voidstar Malloc(), Calloc();
  121. extern char    *strsave();
  122. extern double    drand48();    /* just in case */
  123.  
  124. #endif /* COMMON_H */
  125.